const { BaseCommand } = require("./base");

class DisassembleCommand extends BaseCommand {
    async execute() {
        let delimiter = this.selfData.delimiter;
        if (delimiter) {
            delimiter = new RegExp(delimiter);
        }
        let props = this.selfData.props;
        if (delimiter && typeof props === "string") {
            props = props.split(delimiter);
        }
        const _num_item = this.content.length;
        return props.map((prop, _prop_index) => {
            return this.content.map((v) => {
                return v[prop];
            });
        });
    }

    getRequiredParams() {
        return ["props"];
    }

    getRequireContent() {
        return true;
    }
}

module.exports = {
    DisassembleCommand,
};
